<template>
    <div>
        <div class="search-content" ref="searchCon">
            <slot name="search"></slot>
            <!-- <el-form ref="searchForm" :inline="true" :model="searchContent" label-width="80px">
                <el-form-item>
                    <el-button type="primary" @click="addJd">新增京东商品</el-button>
                </el-form-item>
            </el-form>-->
        </div>
        <div class="search-list">
            <slot name="default" :oHeight="oHeight"></slot>
            <div class="bottom flex-item" ref="bottomCon">
                <div class="btn-group">
                    <slot name="button"></slot>
                </div>
                <!--分页部分-->
                <div class="paginationOne">
                    <el-pagination
                        @size-change="handleSizeChange"
                        @current-change="handleCurrentChange"
                        :current-page="currentPage"
                        :page-sizes="[10, 20, 50, 100]"
                        :page-size="pageSize"
                        layout="total, sizes, prev, pager, next, jumper"
                        :total="total"
                    ></el-pagination>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
import { resize } from '@/common/js/height.js'
import { throttle } from "@/common/js/util.js"
export default ({
    props: ['tableData', 'tableColumn', 'total'],
    data() {
        return {
            oHeight: 0,
            pageSize: localStorage.getItem('pageSize') * 1 || 10,
            currentPage: 1
        }
    },
    methods: {
        handleSizeChange(pageSize) {
            localStorage.setItem('pageSize', pageSize);
            this.pageSize = pageSize;
            this.currentPage = 1;
            this.$emit("getlist", this.currentPage, this.pageSize)
        },
        handleCurrentChange(page) {
            this.currentPage = page;
            this.$emit("getlist", this.currentPage, this.pageSize)
        },
        getHeight() {
            let $a = this.$refs.searchCon;
            let $b = this.$refs.bottomCon;
            var ch = document.documentElement.clientHeight || document.body.clientHeight;
            var oHeight = ch - 50 - 41 - 20 - (parseInt($a.offsetHeight) || 20) - (parseInt($b.offsetHeight) || 0)
            this.oHeight = oHeight;
        },
    },
    mounted() {
        /*
        this.getHeight();
        window.onresize = throttle((event) => {
            console.log(111)
            this.getHeight()
            this.$forceUpdate()
        }, 100)*/
        resize(this)
    }

})
</script>